package _01_动态数组;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class _1403_非递增顺序的最小子序列 {

    public List<Integer> minSubsequence(int[] nums) {
        int len = nums.length;
        int total = 0;
        for (int num : nums) {
            total += num;
        }
        ArrayList<Integer> results = new ArrayList<>();
        Arrays.sort(nums);
        int compareTotal = 0;
        for (int i = len - 1; i >= 0; i--) {
            compareTotal += nums[i];
            results.add(nums[i]);
            if (compareTotal > total - compareTotal) {
                return results;
            }
        }
        return results;
    }

}
